package com.wnxy.eleba.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wnxy.eleba.entity.Customer;
import com.wnxy.eleba.mapper.CustomerMapper;
import com.wnxy.eleba.service.CustomerService_zhuying;
import com.wnxy.eleba.vo.CustomerQueryParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerServiceImpl_zhuying implements CustomerService_zhuying {

    private CustomerMapper customerMapper;

    @Autowired
    public void setCustomerMapper(CustomerMapper customerMapper) {
        this.customerMapper = customerMapper;
    }

    @Override
    public Customer findCustomerById(Integer CustomerId) {
        return customerMapper.selectByPrimaryKey(CustomerId);
    }

    @Override
    public List<Customer> findAll() {
        List<Customer> customerList = customerMapper.showAll();
        return customerList;
    }

    @Override
    public PageInfo<Customer> listCustomerPageByCondition(CustomerQueryParam CustomerQueryParam) {
        PageHelper.startPage(CustomerQueryParam.getCurrentPage(), CustomerQueryParam.getPageSize());
        List<Customer> customerList= customerMapper.selectCustomerByCondition(CustomerQueryParam);
        PageInfo<Customer> pageInfo = new PageInfo<>(customerList);

        return pageInfo;
    }

    @Override
    public boolean saveCustomer(Customer Customer) {

        return customerMapper.insert(Customer)!=0;
    }

    @Override
    public boolean updateCustomer(Customer Customer) {

        return customerMapper.updateByPrimaryKey(Customer)!=0;
    }

    @Override
    public boolean deleteCustomer(Integer[] ids) {

        return false;
    }

    @Override
    public boolean delCustomer(Integer id) {

        return customerMapper.deleteByPrimaryKey(id)!=0;
    }
}
